<template>
  <div class="tree">
    <div class="node">
      {{ treeData.name }}
    </div>
    <div class="line" v-if="treeData.children.length > 0"></div>
    <div class="child-box">
      <Child
        style="flex: 1"
        v-for="(item, index) in treeData.children"
        :key="item.id"
        :treeData="item"
        :isFirst="index == 0"
        :isLast="index == treeData.children.length - 1"
      />
    </div>
  </div>
</template>

<script>
import Child from "./child.vue";
export default {
  name: "Tree",
  components: {
    Child,
  },
  props: {
    treeData: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {};
  },
};
</script>

<style lang="scss" scoped>
.tree {
  display: flex;
  align-items: center;
  width: 100%;
  height: calc(100vh - 400px);
  .node {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
    background-color: #f0f0f0;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    color: #303133;
    border: 1px solid #303133;
  }
  .line {
    width: 100px;
    height: 1px;
    background-color: #303133;
  }
  .child-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
  }
}
</style>
